package com.newspublish.system.utils.util;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
@Component
public class GetMassege {

    public String getUser(){
        Authentication authentication= SecurityContextHolder.getContext().getAuthentication();
        if(authentication!=null){
            String currentPrincipalName = authentication.getName();
            return currentPrincipalName;
        }else{
            System.out.println("请求体为空");
            return null;
        }

    }

}
